<template>
    <div class="ma-content-block  p-4">
      <!-- CRUD 组件 -->
      <ma-crud :options="options" :columns="columns" ref="crudRef">
            <template #pick_number="{ record }">
                <div>{{ record.pick_number }} / {{ record.pick_weight }}</div>
            </template>
            <template #pick_number_all="{ record }">
                <div>{{ record.pick_number_all }} / {{ record.pick_weight_all }}</div>
            </template>
            <template #sy_number="{ record }">
                <div>{{ record.sy_number }} / {{ record.sy_weight }}</div>
            </template>
            <template #yb_number="{ record }">
                <div>{{ record.yb_number }} / {{ record.yb_weight }}</div>
            </template>
            <template #yc_number="{ record }">
                <div style="color:red">{{ record.yc_number }} / {{ record.yc_weight }}</div>
            </template>
            <template #warehouse_user_detail_id="{ record }">
                <div>{{ record.warehouse_user_detail_id == 0?record.work_line + record.transport_number:record.warehouse_name }}</div>
            </template>
      </ma-crud>

      <div style="">
        <div style="display:flex;justify-content: center;margin-bottom:20px;margin-top:20px;">
          <div style="color:red">确认异常件数和重量后，将更正预报或仓储的件数和重量，增加或减少对应件数和重量。</div>
        </div>
        <div style="display:flex;justify-content: flex-end;">
          <a-button type="primary" @click="handleQueDing">确认</a-button>
        </div>
      </div>
    </div>
  </template>
  <script setup>
  import { ref, reactive,defineProps } from 'vue'
  import predictionOrderCar from '@/api/prediction/predictionOrderCar'
  import { Message } from '@arco-design/web-vue'
  import { Notification } from '@arco-design/web-vue'
  
  import tool from '@/utils/tool'
  import * as common from '@/utils/common'
  import { request } from "@/utils/request.js";
  const emits = defineEmits(['upLoadSuccess','handlecolse'])
  const crudRef = ref()
  const id = ref()
  const inforow = ref()
  const dept_ids = ref()
  const props = defineProps({
		row: {
			default: "",
		},
	});
  id.value = props.row.id;
  // const open = (row) => {
  //   order_id.value = row.id
  //   inforow.value = row
  //   crudRef.value.requestData()
  //   }
  
  const handleQueDing = ()=>{
    request({
      url: "prediction/order/confirmOrder",
      method: "get",
      params: {
        id:id.value
      },
    }).then((res) => {
      if(res.code == 200){
        Notification.success("确认成功！");
        setTimeout(()=>{
          emits('handlecolse',false)
        },1000)
      }
      
      
    });
  }
  
  const numberOperation = (newValue, id, numberName) => {
    predictionOrderCar.numberOperation({ id, numberName, numberValue: newValue }).then( res => {
      res.success && Message.success(res.message)
    }).catch( e => { console.log(e) } )
  }
  
  const switchStatus = (statusValue, id, statusName) => {
    predictionOrderCar.changeStatus({ id, statusName, statusValue }).then( res => {
      res.success && Message.success(res.message)
    }).catch( e => { console.log(e) } )
  }
  
  
  const options = reactive({
    id: 'flyos_prediction_order_car',
    rowSelection: {
      showCheckedAll: true
    },
    pk: 'id',
    operationColumn: false,
    autoRequest:true,
    isDbClickEdit:false,
    operationWidth: 160,
    formOption: {
      viewType: 'modal',
      width: 600
    },
    api: predictionOrderCar.confirmList,
    recycleApi: predictionOrderCar.getRecycleList,
    beforeRequest: (params) => {
        params.id = id.value
    },
    afterRequest: (params) => {
      console.log(params, "后置方法");
      params.map((v, i) => {
        v.car_ids = v.car_id
      });
    },
  })
  
  const columns = reactive([
    {
      title: "ID",
      dataIndex: "id",
      formType: "input",
      addDisplay: false,
      editDisplay: false,
      hide: true,
      commonRules: {
        required: true,
        message: "请输入ID"
      }
    },
    {
    title: '批次号',
    dataIndex: 'batch_no',
    align: "center",
    formType: 'input',
    search: false,
    },
    {
      title: '车牌号',
      dataIndex: 'car_no',
      align: "center",
      formType: 'input',
      addDisplay: false,
      editDisplay: false,
    },
    {
      title: '品名',
      dataIndex: 'goods_name',
      align: "center",
      formType: 'input',
      addDisplay: false,
      editDisplay: false,
    },
    
    {
      title: '作业地点',
      dataIndex: 'warehouse_user_detail_id',
      align: "center",
      formType: 'input',
      addDisplay: false,
      editDisplay: false,
    },
    {
      title: '预报件数/计费重量',
      dataIndex: 'yb_number',
      align: "center",
      formType: 'input',
      width:200,
      addDisplay: false,
      editDisplay: false,
    },
    {
      title: '司机提货件数/司机提货重量',
      dataIndex: 'pick_number',
      align: "center",
      formType: 'input',
      width:200,
      addDisplay: false,
      editDisplay: false,
    },
    {
      title: '提单总件数/提单总重量',
      dataIndex: 'pick_number_all',
      align: "center",
      formType: 'input',
      width:200,
      addDisplay: false,
      editDisplay: false,
    },
    {
      title: '剩余件数/剩余重量',
      dataIndex: 'sy_number',
      align: "center",
      formType: 'input',
      width:200,
      addDisplay: false,
      editDisplay: false,
    },
    
    {
      title: '异常件数/异常重量',
      dataIndex: 'yc_number',
      align: "center",
      formType: 'input',
      width:200,
      addDisplay: false,
      editDisplay: false,
    },
    {
      title: "创建时间",
      dataIndex: "created_at",
      formType: "date",
      addDisplay: false,
      editDisplay: false,
      hide: true,
      showTime: true
    }
  ])
  defineExpose({ open })
  </script>
  <script> export default { name: 'prediction:orderCar' } </script>